/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hmm;

import java.util.Arrays;

/**
 *
 * @author noe
 */
public class HMM {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        AlphaBeta ab = new AlphaBeta();
        //ab.AlphaMatrix();
        //ab.BetaMatrix();
        //ab.baulWelch();
        //System.out.println("-------------------------------------------");
       //System.out.println(ab.beta(10, 1));
       //System.out.println(ab.beta(10, 0));
       
         //     System.out.println(ab.alpha(5, 1));
       //System.out.println(ab.alpha(5, 0));
       System.out.println("-------------------------------------------");
       ab.dynamicProgramming();
       System.out.println(ab.sequenceDP());
        //ab.combinations();
        /*System.out.println(String.format("\nAlpha: %1$.6f", ab.alpha(3,0)));
        System.out.println(String.format("\nAlpha pass: %1$.6f", ab.alphaPass()));
        System.out.println(String.format("\nBeta pass: %1$.6f", ab.betaPass()));
        System.out.println(String.format("\nDP solution: P(%2$1S) = %1$.6f", ab.dynamicProgramming(), ab.sequenceDP()));
        System.out.println("");
        // Getting values
        int numStates = ab.getN();
        int time = ab.getT();
        
        String header="", columns="State\t\t", line="";
        
        for(int i=0; i<time/2;i++)
        {
            line += "---------------------------------------";
            header += "\t\t";
        }
        System.out.println(line);
        System.out.println(header +"element");
        
        for(int i=0; i<time; i++)
            columns += String.valueOf(i) + "\t\t";
        System.out.println(columns);
        
        System.out.println(line);        
        
        double[] maxValues = new double[time];
        int [] num = new int[time];
        double tmp;
        for(int i=0; i<numStates; i++)
        {
            String row = "P("+String.valueOf(i)+")    ";
            for(int j=0; j<time; j++)
            {
                tmp = ab.gamma(j, i);
                row += "\t" + String.format("%.6f", tmp);
                if(tmp > maxValues[j])
                {
                    maxValues[j] = tmp;
                    num[j] = i;
                }
            }
            
            System.out.println(row);
        }
        
        System.out.println(String.format("\nHMM solution: %S", Arrays.toString(num))); */   
    }   
}
